<%-- 
    Document   : contentSanPham
    Created on : Oct 21, 2011, 10:51:04 AM
    Author     : Mr.Thanh
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.util.*,model.dao.*,model.pojo.*,model.util.*"%>
<%@taglib prefix="box" uri="/WEB-INF/tlds/boxtag_library.tld" %>
<%
  String table=request.getParameter("page"); 
  int trang=(Integer)request.getAttribute("trang");
  int soTrang=(Integer)request.getAttribute("soTrang");
  HashMap<Vector,ArrayList<adminTableColumnsPOJO>> dsAll;
  if(table!=null )
  {
      
      dsAll=(HashMap<Vector,ArrayList<adminTableColumnsPOJO>>)request.getAttribute("DanhSach");
      if(dsAll!=null&&dsAll.size()>0){
          String lk=String.format("page=%s&action=view", table);
          String FieldId="";
          Iterator iterator = dsAll.keySet().iterator();
                  //get key
                  Vector vt=(Vector)iterator.next();
                  //get value
                  ArrayList<adminTableColumnsPOJO> cols=dsAll.get(vt);  
                  //lay ten column la khoa chinh de dung select ra dong voi doi so ten column, ma
                  if(cols!=null && cols.get(0)!=null){
                     FieldId=cols.get(0).getField();     
                  }                                                              
         %>                  
                          <jsp:include page="/pages/boxPhanTrang.jsp">
                               <jsp:param name="trang" value="<%=trang%>"/>
                               <jsp:param name="soTrang" value="<%=soTrang%>"/>
                               <jsp:param name="lienKet" value="<%=lk%>"/>
                           </jsp:include>                     
            
            <div class="boxDisplay">   
                 <form id="frmTable" name="frmTable" method="post" >                
              <table width="100%">                
                  
                  <tr>
                  <td class="boxDisplay_ColAction"><input type="checkbox" name="chkTable" id="chkTable"></td>       
                   <td class="boxDisplay_ColAction" ><a class="ajaxActionEditAll LienKet[page=<%=table%>&action=edit&KeyColumnName=<%=FieldId%>]" title="Edit" href="javaScript:void(0);"><img src="images/edit.png" alt="Edit" width="16" height="16"></a></td>
                  <td class="boxDisplay_ColAction" ><a class="ajaxActionDeleteAll LienKet[page=<%=table%>&action=delete&KeyColumnName=<%=FieldId%>]"  title="Delete" href="javaScript:void(0);"><img src="images/delete.png" alt="Delete" width="16" height="16"></a></td>
                  <td class="boxDisplay_ColAction" ><a class="ajaxAction LienKet[page=<%=table%>&action=insert]" title="Insert" href="javaScript:void(0);"><img src="images/Add.png" alt="Insert" width="16" height="16"></a></td>
                  
                  <%                 
                  
                  for(adminTableColumnsPOJO s:cols){
                      %>
                     <td><strong><%=s.getField()%></strong></td>
                  <%
                  }
                %>                  
                                 
                </tr>
<%
           iterator = dsAll.keySet().iterator();
           while(iterator.hasNext()){
               vt=(Vector)iterator.next();
                
          %>
                <tr>
                  <td class="boxDisplay_ColAction"><input type="checkbox" name="chkId" value="<%=vt.get(0)%>"></td>                  
                  <td class="boxDisplay_ColAction" ><a class="ajaxActionEdit LienKet[page=<%=table%>&action=edit&KeyColumnName=<%=FieldId%>&id=<%=vt.get(0)%>]" title="Edit" href="javaScript:void(0);"><img src="images/edit.png" alt="Edit" width="16" height="16"></a></td>
                  <td class="boxDisplay_ColAction" ><a class="ajaxActionDelete LienKet[page=<%=table%>&action=delete&KeyColumnName=<%=FieldId%>&id=<%=vt.get(0)%>]" title="Delete" href="javaScript:void(0);"><img src="images/delete.png" alt="Delete" width="16" height="16"></a></td>
                  <td class="boxDisplay_ColAction" ></td>
                  <%
                  
                  for(int i=0;i<vt.size();i++){%>
                       <td><%=vt.get(i)%></td>   
                  <%}%>
                </tr>
                <%                    
           }
          %>
          </table>        
                 </form>
        </div>
<%
      } else{
          %>
        <div class="boxDisplay">            
                         
              <table width="100%">                
                  
                  <tr>                        
                  <td class="boxDisplay_ColAction"><input type="checkbox" name="chkTable" id="chkTable"></td>       
                   <td class="boxDisplay_ColAction" ><img src="images/edit.png" alt="Edit" width="16" height="16"></td>
                  <td class="boxDisplay_ColAction" ><img src="images/delete.png" alt="Delete" width="16" height="16"></td>
                  <td class="boxDisplay_ColAction" ><a class="ajaxAction LienKet[page=<%=table%>&action=insert]" title="Insert" href="javaScript:void(0);"><img src="images/Add.png" alt="Insert" width="16" height="16"></a></td>
                  <td colspan="5" align="center" style="color:#093"><strong>Chưa có dữ liệu</strong></td>
                 </tr>
                 
              </table>
              
        </div>
                 
<%
      }     
      
  }
  %>
